Module: hooks/useSmartFetch
Type Aliases
BaseState
Ƭ BaseState: Object
Type declaration
Name | Type |
---|---|
refetch | () => Promise <void > |
Defined in
src/web-app/src/hooks/useSmartFetch.tsx:5
ErrorState
Ƭ ErrorState<TError
>: BaseState
& { data
: null
; error
: TError
; isError
: true
; isLoading
: false
; status
: "error"
}
Type parameters
Name |
---|
TError |
Defined in
src/web-app/src/hooks/useSmartFetch.tsx:25
LoadingState
Ƭ LoadingState: BaseState
& { data
: null
; error
: null
; isError
: false
; isLoading
: true
; status
: "loading"
}
Defined in
src/web-app/src/hooks/useSmartFetch.tsx:9
SmartFetchState
Ƭ SmartFetchState<TData
, TError
>: LoadingState
| SuccessState
<TData
> | ErrorState
<TError
>
Type parameters
Name |
---|
TData |
TError |
Defined in
src/web-app/src/hooks/useSmartFetch.tsx:33
SuccessState
Ƭ SuccessState<TData
>: BaseState
& { data
: TData
; error
: null
; isError
: false
; isLoading
: false
; status
: "success"
}
Type parameters
Name |
---|
TData |
Defined in
src/web-app/src/hooks/useSmartFetch.tsx:17
Functions
useSmartFetch
▸ useSmartFetch<TData
, TError
>(root0
): SmartFetchState
<TData
, TError
>
Simple hook for fetching data once.
Type parameters
Name | Type |
---|---|
TData | TData |
TError | unknown |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
root0 | Object | undefined | Options object. |
root0.enabled? | boolean | true | Whether the query should be executed. |
root0.queryFn | () => Promise <TData > | undefined | Query function to wrap with smart fetch. |
Returns
SmartFetchState
<TData
, TError
>